package com.edu.javaweb.mapper;

import com.edu.javaweb.pojo.StudentRecord;
import com.edu.javaweb.vo.Rule;
import com.edu.javaweb.vo.StudentRecordVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentRecordMapper {

    @Insert("insert into studentrecord values " +
            "(null,#{type},#{addr},#{beginTime},#{endTime},#{contact1},#{contact2},#{traffic})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void insStuRecord(StudentRecord studentRecord);

    @Insert("insert into sturecord_holidayinfo values (null,#{stuId},#{stuRecordId},#{stuRecInfoId})")
    void insStuAndStuRecord(@Param("stuId") Integer stuId, @Param("stuRecordId") Integer stuRecordId,@Param("stuRecInfoId") Integer stuRecInfoId);

    @Select("select sr.* from sturecord_holidayinfo sh left join studentrecord sr on sh.stu_record_id=sr.id where sh.stu_id=#{stu}")
    List<StudentRecord> findByStuId(Integer stu);
    List<StudentRecordVo> findByStuRecordGroup(Rule rule);
}
